package com.jxmcloud.business.cut.service.impl.database;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jxmcloud.business.cut.mapper.database.IUserAwardInfoDBMapper;
import com.jxmcloud.business.cut.model.database.DBUserAwardInfo;
import com.jxmcloud.business.cut.service.database.IUserAwardInfoDBService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserArardInfoDBServiceImpl extends ServiceImpl<IUserAwardInfoDBMapper, DBUserAwardInfo> implements IUserAwardInfoDBService {
    @Override
    public boolean insertIntoData(DBUserAwardInfo info) {
        return this.baseMapper.insert(info) == 1;
    }

    @Override
    public DBUserAwardInfo selectOne(Integer uid) {
        return this.baseMapper.selectById(uid);
    }

    @Override
    public List<DBUserAwardInfo> selectAll(Integer uid, Integer activityId) {
        QueryWrapper<DBUserAwardInfo> wrapper = new QueryWrapper<>();
        wrapper.eq("uid", uid);
        wrapper.eq("activity_id", activityId);
        return this.baseMapper.selectList(wrapper);
    }

    @Override
    public boolean deleteData(Integer uid, Integer activityId) {
        QueryWrapper<DBUserAwardInfo> wrapper = new QueryWrapper<>();
        wrapper.eq("uid", uid);
        wrapper.eq("activity_id", activityId);
        return this.baseMapper.delete(wrapper) > 0;
    }
    @Override
    public boolean deleteData(Integer uid) {
        QueryWrapper<DBUserAwardInfo> wrapper = new QueryWrapper<>();
        wrapper.eq("uid", uid);
        return this.baseMapper.delete(wrapper) > 0;
    }

    @Override
    public boolean updateData(DBUserAwardInfo info) {
        return this.baseMapper.updateById(info) == 1;
    }
}
